package sel.me.spring.boot159.web;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.annotation.ImportResource;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import sel.me.spring.boot159.web.annotation.TestAnnotation;

import java.util.concurrent.ThreadPoolExecutor;

@EnableFeignClients(basePackages = "sel.me.spring.boot159.web.feign")
//@EnableEurekaClient
//@EnableScheduling
//@SpringCloudApplication
//@EnableTransactionManagement
@EnableScheduling
@EnableAsync
@ImportResource({ "classpath:spring/spring-*.xml" })
@TestAnnotation
//@EnableEurekaClient

/**
 * 启动项目，打开：
 *
 * http://localhost:10070/hystrix
 *
 * 输入：
 *
 * http://localhost:10070/hystrix.stream
 * 我们使用wrk模拟请求：
 *
 * wrk -c 10 -t 10 -d 20s http://localhost:10070/add
 * 然后dashboard中发生了变化：
 */
@EnableCircuitBreaker
@EnableHystrixDashboard
@SpringBootApplication(exclude =  { DataSourceAutoConfiguration.class
        , ThymeleafAutoConfiguration.class
//        , RedisAutoConfiguration.class
        , EurekaClientAutoConfiguration.class
//        , RedisRepositoriesAutoConfiguration.class
})
public class StartupApplication {



    public static void main(String[] args) throws Exception {
//        JedisConnectionFactory j;
//        StringRedisSerializer s;
//        StopWatch sw;
//
//        PageInterceptor p;
//        p.setProperties();
//        AnnotationConfigEmbeddedWebApplicationContext a;
//
//        ApplicationContextInitializer ac;
//        ApplicationListener al;
//        RollingFileAppender aaa;
//        SizeAndTimeBasedRollingPolicy bbb
//        org.springframework.boot.logging.logback

//        HystrixCommandAspect s;

//        RedisTemplate redisTemplate;

//        redisTemplate.opsForValue().setIfAbsent()
//        ConfigurationClassPostProcessor sss;

//        BeanDefinition bd;
//        JedisClusterConnection jedisClusterConnection;
        ThreadPoolExecutor s;
        SpringApplication.run(StartupApplication.class, args);

    }




//    @Bean
//    public ServletRegistrationBean getServlet(){
//        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
//        ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
//        registrationBean.setLoadOnStartup(1);
//        registrationBean.addUrlMappings("/hystrix.stream");
//        registrationBean.setName("HystrixMetricsStreamServlet");
//        return registrationBean;
//    }


}
